﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Blog.IRepository
{
    public interface IBaseRepository<TEntity> where TEntity : class, new()
    {
        Task<bool> Create(TEntity tentity);
        Task<bool> Delete(int Id);
        Task<bool> Edit(TEntity tentity);
        Task<TEntity> Find(int Id);
        Task<TEntity> Find(Expression<Func<TEntity,bool>> func);

        //全部查询
        Task<List<TEntity>> Query();

        //条件查询
        Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> func);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name=""></param>
        /// <param name="total"></param>
        /// <returns></returns>
        Task<List<TEntity>> Query(int page, int size, RefAsync<int> total);

        Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> func, int page, int size, RefAsync<int> total);
    }
}
